<?php

include_once 'db/Crud.php';

class Freguencia extends Crud {
    protected $table = freguencia;
    private $data;
    private $idUsuario;
    private $idTurma;
    private $idSerie;
    private $justifica;
    
    public function getTable() {
        return $this->table;
    }

    public function getData() {
        return $this->dateToBR($this->data);
    }

    public function getIdUsuario() {
        return $this->idUsuario;
    }

    public function getIdTurma() {
        return $this->idTurma;
    }

    public function getIdSerie() {
        return $this->idSerie;
    }

    public function getJustifica() {
        return $this->justifica;
    }

    public function setTable($table) {
        $this->table = $table;
    }

    public function setData($data) {
        $this->data =  $this->dateToUS($data) ;
    }

    public function setIdUsuario($idUsuario) {
        $this->idUsuario = $idUsuario;
    }

    public function setIdTurma($idTurma) {
        $this->idTurma = $idTurma;
    }

    public function setIdSerie($idSerie) {
        $this->idSerie = $idSerie;
    }

    public function setJustifica($justifica) {
        $this->justifica = $justifica;
    }

    

    public function insert() {
        $sql = "INSERT INTO $this->table (fre_data, fre_usu_id, fre_tur_id, fre_ser_id, fre_justifica) VALUES (:data, :idUsuario, :idTurma, :idSerie, :jusitifica)";
        $stmt = Db::prepare($sql);
        $stmt->bindParam(':data', $this->data);
        $stmt->bindParam(':idUsuario', $this->idUsuario);
        $stmt->bindParam(':idTurma', $this->idTurma);
        $stmt->bindParam(':idSerie', $this->idSerie);
        $stmt->bindParam(':justifica', $this->justifica);
        return $stmt->execute();
        
    }

    public function update($id) {
        $sql = "UPDATE $this->table SET fre_data = :data, fre_usu_id = :idUsuario, fre_tur_id = :idTurma, fre_ser_id = :idSerie, fre_justifica = :justifica WHERE id = :id";
        $stmt = Db::prepare($sql);
        $stmt->bindParam(':data', $this->data);
        $stmt->bindParam(':idUsuario', $this->idUsuario);
        $stmt->bindParam(':idTurma', $this->idTurma);
        $stmt->bindParam(':idSerie', $this->idSerie);
        $stmt->bindParam(':justifica', $this->justifica);
        $stmt->bindParam(':id', $id);
        return $stmt->execute();
        
    }


}
